//------------------------------------------------------------------------------
// <copyright file="WindowAddNewObject.xaml.cs" company="Damian Antonowicz">
//       copyright © 2010 Damian Antonowicz
// </copyright>
// <author>Damian Antonowicz</author>
// <email>poczta@damianantonowicz.pl</email>
//------------------------------------------------------------------------------

using System;
using System.Windows;

namespace DotBeer.UI.WPFClient
{
    /// <summary>
    /// Interaction logic for WindowAddNewHero.xaml
    /// </summary>
    public partial class WindowAddNewObject : Window
    {
        #region private members

        bool _itemAdded = false;
        string _newObjectName = "";

        #endregion

        #region constructors

        public WindowAddNewObject(string title)
        {
            InitializeComponent();

            this.DataContext = this;

            this.Title = String.Format("Add new {0}", title);
            this.TextBoxName.Focus();
        }

        #endregion

        #region properties

        public string NewObjectName
        {
            get { return _newObjectName; }
            set { _newObjectName = value; }
        }

        #endregion

        #region private methods

        #region user actions

        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            _itemAdded = true;
            this.DialogResult = true;
        }

        #endregion

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!_itemAdded)
                CancelAdding();
        }

        private void CancelAdding()
        {
            this.DialogResult = false;
        }

        #endregion
    }
}
